*******************************************************************************
****				Appendix Table G.6 - REGRESSION OF DISTANCE ON EXIT TIME					*******************************************************************************
*******************************************************************************

use ".\data\clean\I10W_laneuse_dataset_15nov14_wcensus", clear
merge m:1 date hour using ".\data\clean\HV_ML_reliab.dta", keep(1 3) nogen 
gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV

*WTP calculation
gen TT_dif_hr=dist/MLspeed-dist/ELspeed
gen WTP2=charged_toll/TT_dif_hr
drop if ELspeed==.
drop if TT_dif_hr==.
drop if holiday==1
la var TT_dif_hr "Time in Hours"
drop if dow==0|dow==6
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
g exittime=hh(exit_time)+mm(exit_time)/60+ss(exit_time)/(60*60)
egen exittimemean=mean(exittime), by(acct_no)
g exittime2=exittime*exittime
la var exittime "Exit Time"
la var exittime2 "Exit Time2"
g toll=charged_toll/dist
la var toll "Toll in Dollars per Mile"
keep if hour>4 & hour<9
egen aid=group(acct_no)
egen tid=group(transponder)
est sto clear
reg dist exittime toll if TT_dif_hr>0, cluster(rt_id) 
est sto a1
areg dist exittime  toll, a(aid) vce(cl rt_id)
est sto a2
areg dist exittime  toll, a(tid) vce(cl rt_id)
est sto a3
reg dist exittime exittime2 toll, cluster( rt_id)
est sto a4
reg dist exittime toll if TT_dif_hr>0 & rt_id!=5, cluster(rt_id) 
est sto a5

esttab  a1 a2 a3 a4 a5 using ".\results\appendix\tabs\ATG6.csv", replace  nonumbers nodepvars ///
	cells(b(star fmt(%9.2f)) se(par)) star(* 0.10 ** 0.05 *** 0.01) stats(r2 N ,fmt(%9.2f %9.0f) ) label ///
	order(exittime exittime2 toll _cons)  mtitle("I" "II" "III" "IV" "V") 
insheet using ".\results\appendix\tabs\ATG6.csv", comma clear
export excel using ".\results\appendix\AppendixFigsTabs.xlsx", ///
	sheet("Appendix Table G.6", replace) 
